//Sat 30 Jan 2010 03:37:53 AM CST 
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

int xx[] = {1,0,-1,0};
int yy[] = {0,1,0,-1};

class Desertification
{
public:
	int desertArea(vector <string> island, int T)
	{
		land = island;
		Times = T;
		int ret = 0;
		for(int i=0; i<land.size(); i++)
		{
			for(int j=0; j<land[i].size(); j++)
			{
				int dis = 1<<30;
				for(int p=0; p<land.size(); p++)
				{
					for(int q=0; q<land[p].size(); q++)
					{
						if(land[p][q] == 'D')
						dis = min(dis, abs(i-p)+abs(j-q));
					}
				}
				if(dis <= T) ret++;
			}
		}
		return ret;
	}
	vector<string> land;
	int Times;
};
